// pages/address/address.js




var app = getApp();
var url1 = "";
import drawQrcode from '../../utils/weapp.qrcode.esm.js'
Page({
  onLoad() {
    wx.request({
      url: 'http://localhost/test',
      data: {

      },
      type: "post",
      datatype: "json",
      success: function (data) {
        wx.setStorageSync('member', data.data);
        var as = wx.getStorageSync("member");
      }
    });
  },

  openShare() {
    //分享功能实现

    /*var itemList = [
      "分享给微信好友",
      "分享到朋友圈",
      "分享到QQ",
      "分享到微博",
    ]*/
    /* wx.showActionSheet({
       itemList: itemList,
       itemColor: '#405f80', //设置元素的颜色
       success: function (res) {
         //用户是不是点击了取消按钮res. cancel
         //res . tapIndex数组元素的序号从e开始
         Wx.showModal({
           title: ' 用户' + itemList[res.tapIndex],
           content: ' 用户是否取消? ' + res.cancel + '现在无法实现分享功能',
         })
       }
     });*/

    drawQrcode({
      width: 200,
      height: 200,
      canvasId: 'myQrcode',
      text: 'https://www.huazhuan.net',
      /*image: {
        imageResource: '../../images/mao.jpg',
        dx: 80,
        dy: 80,
        dWidth: 30,
        dHeight: 30
      }*/
    });

    /* var url = "21";
     this.createQrCode(url, 300, 300);
   },
   createQrCode: function(content, cavw, cavh) {
     var canvasId = "mycanvas";
     QR.api.draw(content, canvasId, cavw, cavh);
     this.canvasToTempImage(canvasId);
   },
   canvasToTempImage: function(canvasId){
     var that=this;
     wx.canvasToTempFilePath({
       "canvasId": 'canvasId',
       success:function (res){
         var tempFilePath = res.tempFilePath;
         that.setData({
           "imagePath": tempFilePath
         });
       }
     });
   }*/


  },

  onShareAppMessage: function () {

    console.log(url1);
    return {
      title: '注册',
      path: '/pages/register/register?' + url1,
      success: function (res) {

      }
    }
    /*uni.share({
      provider: "weixin",
      scene: "WXSceneSession",
      type: 1,
      summary: "我正在使用HBuilderX开发uni-app，赶紧跟我一起来体验！",
      success: function (res) {
        console.log("success:" + JSON.stringify(res));
      },
      fail: function (err) {
        console.log("fail:" + JSON.stringify(err));
      }
    });*/


  },

  getYao() {
    url1 = "invitationUserId=7&codew=9kl856";
    console.log(21);
    wx.request({
      url: 'http://192.168.0.100/generateInvitationCode',
      data: {

      },
      type: "post",
      dataType: "json",
      async: false,
      success: function (data) {
        var codew = data.data;
        url1 += codew;
        console.log(url1);

      }

    });
    /* var list = ['分享到微信好友', "分享到QQ好友"];
     wx.showActionSheet({
       itemList: list,
       success: function (res) {
         if (res.tapIndex == 0) {
           this.onShareAppMessage();
         }
       }
     });*/
  },
  dibu() {

  }

});